package flashSecurityServer;

import java.net.InetSocketAddress;

import org.apache.log4j.Logger;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

import flashSecurityServer.handler.BasicHandler;
import flashSecurityServer.handler.MessageFilter;
import flashSecurityServer.handler.PolicyFileLoader;
import flashSecurityServer.log.EbocyLogManager;


public class FlashSecurityServer {
	protected static Logger logger = EbocyLogManager.getSystemLogger();
	private static final int PORT = 7899;

	public static void main(String[] args) throws Exception {
		PolicyFileLoader.loadPolicyFile();
		NioSocketAcceptor acceptor = new NioSocketAcceptor();
		acceptor.getFilterChain().addLast("message", new MessageFilter());
		acceptor.getSessionConfig().setTcpNoDelay(true);
		acceptor.setHandler(new BasicHandler());
		acceptor.bind(new InetSocketAddress(PORT));
		logger.info("FlashSecurityServer started on port " + PORT);
	}
}
